package jdbc;

import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class LoginTest {
    public static void main(String[] args) {
        try(
                Connection conn=DBUtil.getConnection();
        ){
            Statement statement=conn.createStatement();

            String sql="SELECT id, username,password,nickname,age FROM userinfo WHERE username='王克晶' AND password='123456'";
            System.out.println(sql);
            ResultSet rs= statement.executeQuery(sql);
            while (rs.next()){
                byte[] nicknameBytes = rs.getBytes("nickname");
                String nickname = new String(nicknameBytes, StandardCharsets.UTF_8);


                System.out.println(nickname);
            }

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
